package com.kaifamiao.wendao.servlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

@WebServlet( "/image/show/*" )
public class ImageShowServlet extends HttpServlet {

    private String location ;

    @Override
    public void init() throws ServletException {
        ServletContext application = this.getServletContext();
        location = application.getInitParameter( "imageStoreLocation" );
        System.out.println( location );
    }

    @Override
    protected void doGet(HttpServletRequest request , HttpServletResponse response ) throws ServletException, IOException {

        System.out.println( request.getRequestURL() ); // StringBuffer
        System.out.println( request.getRequestURI() ); // String

        /*
        String filename = request.getParameter( "filename" );
        System.out.println( filename );
        File fod = new File( location , filename );
        if( fod.isFile() ) {
            System.out.println( file );
        }*/
    }
}
